package cn.iocoder.yudao.module.shop.dal.mysql.userholiday;

import java.time.LocalDateTime;
import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.shop.dal.dataobject.userholiday.ShopUserHolidayDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.shop.controller.admin.userholiday.vo.*;

/**
 * 艾灸师请假 Mapper
 *
 * @author 曹建伟
 */
@Mapper
public interface ShopUserHolidayMapper extends BaseMapperX<ShopUserHolidayDO> {

    default PageResult<ShopUserHolidayDO> selectPage(ShopUserHolidayPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ShopUserHolidayDO>()
                .eqIfPresent(ShopUserHolidayDO::getUserId, reqVO.getUserId())
                .betweenIfPresent(ShopUserHolidayDO::getHolidayTime, reqVO.getHolidayTime())
                .betweenIfPresent(ShopUserHolidayDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ShopUserHolidayDO::getId));
    }

    default List<ShopUserHolidayDO> selectList(ShopUserHolidayExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<ShopUserHolidayDO>()
                .eqIfPresent(ShopUserHolidayDO::getUserId, reqVO.getUserId())
                .betweenIfPresent(ShopUserHolidayDO::getHolidayTime, reqVO.getHolidayTime())
                .betweenIfPresent(ShopUserHolidayDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ShopUserHolidayDO::getId));
    }

    default List<ShopUserHolidayDO> selectListByTime(LocalDateTime startTime, LocalDateTime endTime, Long tenantId){
        return selectList(new LambdaQueryWrapperX<ShopUserHolidayDO>()
                .eq(ShopUserHolidayDO::getTenantId, tenantId)
                .between(ShopUserHolidayDO::getHolidayTime, startTime, endTime));
    }

    default Long selectCountByTime(Long userId, LocalDateTime holidayTime){
        return selectCount(new LambdaQueryWrapperX<ShopUserHolidayDO>()
                .eq(ShopUserHolidayDO::getUserId, userId)
                .eq(ShopUserHolidayDO::getHolidayTime, holidayTime));
    }

}
